---
import BasicMarkdownLayout from "@/layouts/BasicMarkdownLayout/index.astro";
import type { GetStaticPaths } from "astro";
import { ItemList, BasicList } from "../_utils/getContentList";
import ItemListComponent from "../_components/ItemList.astro";
import BasicListComponent from "../_components/BasicList.astro";

export interface Props {
  type: string;
  name: string;
  data: any;
}

export const getStaticPaths = (() => {
  return [
    {
      params: {
        type: "items",
      },
      props: {
        type: "items",
        name: "物品",
        data: ItemList,
      },
    },
    ...BasicList.map(({ path, name, list }) => ({
      params: {
        type: path,
      },
      props: {
        type: path,
        name,
        data: list,
      },
    })),
  ];
}) satisfies GetStaticPaths;

const { type, name, data } = Astro.props;
---

<BasicMarkdownLayout
  title={`词条一览 - ${name}`}
  showEdit={false}
  color="#976961"
  pagefindIgnore
>
  <p>
    该页面用于收录所有 <strong>{name}</strong> 相关的词条。
  </p>
  <p>该部分修改需要加入 Wiki 管理群进行反馈。管理群:831277455</p>
  <h2>{name}一览</h2>
  {
    (() => {
      switch (type) {
        case "items":
          return <ItemListComponent ItemList={data} />;
        default:
          return <BasicListComponent BasicList={data} />;
      }
    })()
  }
</BasicMarkdownLayout>
